package org.jeecg.modules.yw.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


@Configuration
public class InterceptorConfig implements WebMvcConfigurer{
	  /**
     * 在实现WebMvcConfigurer之后可以选择你要重写的方法，这里重写addInterceptors这个方法来添加自定义的拦截器。
     *     addInterceptor用于添加你自定义的拦截器实例
     *     addPathPatterns用于添加要拦截的url,可以写多个。
     *     excludePathPatterns用于添加不需要拦截的url,可以写多个。
     */    
    @Bean
    public JWTInterceptor getTotalInterceptor(){
        return new JWTInterceptor();
    } 
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration interceptorRegistration = registry.addInterceptor(getTotalInterceptor());       
        interceptorRegistration.addPathPatterns("/**").excludePathPatterns("/app/enterpriseInfo/addEnterPrise")
        .excludePathPatterns("/app/enterpriseInfo/login")
        .excludePathPatterns("/app/enterpriseInfo/logout")
        .excludePathPatterns("/app/enterpriseInfo/sendCode")
        .excludePathPatterns("/app/enterpriseInfo/checkCode")
        .excludePathPatterns("/app/announcements/pageRoleid")
        .excludePathPatterns("/app/info/articleByCategory")
        .excludePathPatterns("/app/file/upload");
        
    }
}
